<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 成绩管理系统</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/login/login.css') }}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <script src="{{ url_for('static', filename='js/login/login.js') }}"></script>
</head>
<body>
  <div class="login-container">
    <div class="login-title">
      <i class="fas fa-graduation-cap"></i>
      系统登录
    </div>
    {% if message %}
    <div class="message {{ message_type }}">
        <i class="fas fa-{{ 'check-circle' if message_type == 'success' else 'exclamation-triangle' }}"></i>
        {{ message }}
    </div>
    {% endif %}
    <form id="login-form" method="post" action="/login_post">
      <div class="form-group">
        <div class="input-wrapper">
          <i class="fas fa-user input-icon"></i>
          <input id="form-input-username" type="text" required
                 value="{{ form_data.username if form_data else '' }}{{ form_data.sno if form_data else '' }}">
        </div>
        {% if errors and errors.username %}
        <div class="field-error">
          <i class="fas fa-exclamation-circle"></i>
          {{ errors.username }}
        </div>
        {% endif %}
      </div>
      <div class="form-group">
        <div class="input-wrapper">
          <i class="fas fa-lock input-icon"></i>
          <input id="form-input-password" name="password" placeholder="请输入密码" type="password" required
                 value="{{ form_data.password if form_data else '' }}">
        </div>
        {% if errors and errors.password %}
        <div class="field-error">
          <i class="fas fa-exclamation-circle"></i>
          {{ errors.password }}
        </div>
        {% endif %}
      </div>
      <div class="form-group">
        <div class="input-wrapper">
          <i class="fas fa-user-tag input-icon"></i>
          <select class="form-group-select" name="role">
            <option value="0" {{ 'selected' if form_data and form_data.role == '0' else '' }}>学生</option>
            <option value="1" {{ 'selected' if form_data and form_data.role == '1' else '' }}>管理员</option>
            <option value="2" {{ 'selected' if form_data and form_data.role == '2' else '' }}>超级管理员</option>
          </select>
        </div>
      </div>

      <button type="submit" class="submit-btn">
        <i class="fas fa-sign-in-alt"></i>
        登录
      </button>
    </form>
    <div class="register-link">
      <a href="/admin/register">
        <i class="fas fa-user-plus"></i>
        还没有账号？点击注册
      </a>
    </div>
  </div>
</body>
</html>